(function() {
	function middle_valign_site_header() {
		var element = $('#site_header');
		if (element.length) {
			if ($(window).innerWidth() >= 768)
				element.css('margin-top', (element.parent().height() - element.height()) / 2);
			else
				element.css('margin-top', "");
		}
	}
	
	function set_body()
	{
		var window_height = $(window).innerHeight()
		var body_height = $('body').height();
		if (body_height + 60 < window_height)
		{
			$('body').height(window_height - 60);
		}
	}
	
	function scale_height()
	{
		var h = 0;
		$('#nhom_san_pham .row .san_pham_xem_truoc > div').each(function(i, e){ if ($(e).height() > h) {h = $(e).height()} });
		$('#nhom_san_pham .row .san_pham_xem_truoc > div').height(h).css('position', 'relative');
		$('#nhom_san_pham .row .san_pham_xem_truoc .noi_dung_dai_dien').css('position', 'absolute').css('bottom', '10px').css('width', '100%');
	}


	$(document).ready(function() {
		set_body();
		middle_valign_site_header();
		$(window).resize(middle_valign_site_header);
		$('.tieu_de_slug').keyup(function(){
			var _slug = slug($(this).val());
			$('.slug_cho_tieu_de').val(_slug);
		});
		$('.datepicker').datepicker()
		scale_height();
	});
	
})();
